package com.zcx.net;

import android.app.Activity;
import android.telephony.TelephonyManager;

import com.zcx.app.AppConfig;
import com.zcx.base.BaseApplication;
import com.zcx.common.Helper;

/**
 * Created by hp on 2017/10/30.
 */

public class IdHelper {

    public static String getId(String id) {
        String temp = String.valueOf(Integer.valueOf(id) / 5);
        return temp.substring(0, 3 > temp.length() ? temp.length() : 3);
    }

    /**
     * 取得IMEI号
     *
     * @return
     */
    public static String getIMEI() {
        try {
            TelephonyManager tm = (TelephonyManager) BaseApplication.getInstance().getSystemService(Activity.TELEPHONY_SERVICE);
            String imei = tm.getDeviceId();
            if (Helper.isEmpty(imei))
                return getRandom();
            else
                return imei;
        } catch (Exception e) {
            return getRandom();
        }
    }

    public static String getRandom() {
        return AppConfig.getImei();
    }

}
